package com.tengju.data.infrastructure.repository.clickhouse.convert;

import com.tengju.data.domain.model.clickhouse.BrandId;
import com.tengju.data.domain.model.clickhouse.dashboard.DashBoardMarketInfo;
import com.tengju.data.domain.model.user.UserIdCode;
import com.tengju.data.infrastructure.persistence.mybatis.dataobject.DashBoardMarketDO;
import org.apache.commons.collections.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @Date: 2021/5/6 21:58
 * @Description:
 */
public class DashBoardMarketConvert {


    public static List<DashBoardMarketInfo> doListToModelList(List<DashBoardMarketDO> doList) {
        List<DashBoardMarketInfo> infoList = new ArrayList<>();
        if (CollectionUtils.isEmpty(doList)) {
            return infoList;
        }
        for (DashBoardMarketDO dash : doList) {
            DashBoardMarketInfo info = new DashBoardMarketInfo(new BrandId(dash.getBranId()),dash.getBrandName(),dash.getSellAcount(),dash.getHodeRatio(),
                    dash.getVisitDate() == null ? "" : dash.getVisitDate());
            infoList.add(info);
        }
        return infoList;
    }

    public static List<UserIdCode> toUserIdCodeList(List<Long> idCodeList) {
        List<UserIdCode> userIdCodeList = new ArrayList<>();
        if (CollectionUtils.isEmpty(idCodeList)) {
            return userIdCodeList;
        }
        idCodeList.forEach(e -> {
            userIdCodeList.add(new UserIdCode(e));
        });
        return userIdCodeList;
    }

}
